<template>
   <el-container class="bg-white rounded" :style="{height :(h + 'px')}">
      <el-header class="image-header">
        <el-button type="primary" size="small" @click="handleOpenCreate">新增图片分类</el-button>
        <el-button type="warning" size="small" @click="handleOpenUpload">上传图片</el-button>
      </el-header>
      <el-container>
        <ImageAside ref="ImageAsideRef" @change="handleAsideChange"/>
        <ImageMain  ref="ImageMainRef"/>
      </el-container>
    </el-container>
</template>

<script setup>
import ImageAside from '@/components/ImageAside.vue'
import ImageMain from '@/components/ImageMain.vue'
import { ref } from 'vue'

// 减去的是标题、导航栏和padding
const windowHeight =  window.innerHeight || document.body.clientHeight
const h = windowHeight - 64 - 44 -40

const ImageAsideRef = ref(null)
const handleOpenCreate = () => ImageAsideRef.value.handleCreate()

//需要先拿到侧边栏分类的id,之后再去渲染对应的数据
const ImageMainRef = ref(null)
const handleAsideChange = (image_class_id)=> ImageMainRef.value.loadDate(image_class_id)

//上传图片
const handleOpenUpload = ()=>ImageMainRef.value.openUploadFile()
</script>

<style scoped>
.image-header{
  border-bottom:1px solid #eeeeee;
  @apply flex items-center
}

</style>